puts "INFO: Running script [info script] @ [exec date]\n"

set_table_style -no_frame_fix_width

#power
#redirect $report_dir/${DESIGN_NAME}.power.rpt {report_power -view mission.sm40.cworst}
#redirect -append $report_dir/${DESIGN_NAME}.power.rpt {report_power -view mission.f125.cbest}


# congestion
reportCongestion -hotspot -overflow > $report_dir/${DESIGN_NAME}.congestion

# density
reportDensityMap > $report_dir/${DESIGN_NAME}.density

# check place
checkPlace > $report_dir/${DESIGN_NAME}.check_place.rpt


###############################################################
# mode setting
###############################################################
redirect         $report_dir/${DESIGN_NAME}.mode_setting.rpt {getDesignMode     -command}
redirect -append $report_dir/${DESIGN_NAME}.mode_setting.rpt {getPlaceMode     -command}
redirect -append $report_dir/${DESIGN_NAME}.mode_setting.rpt {getOptMode     -command}
redirect -append $report_dir/${DESIGN_NAME}.mode_setting.rpt {getAnalysisMode     -command}
redirect -append $report_dir/${DESIGN_NAME}.mode_setting.rpt {getDelayCalMode     -command}
redirect -append $report_dir/${DESIGN_NAME}.mode_setting.rpt {getExtractRCMode     -command}
redirect -append $report_dir/${DESIGN_NAME}.mode_setting.rpt {getNanoRouteMode     -command}
redirect -append $report_dir/${DESIGN_NAME}.mode_setting.rpt {getRouteMode     -command}


###############################################################
# pre Place
###############################################################
if {$current_step == "import" || $current_step == "floorplan"} {
		timeDesign -expandedViews -prePlace -prefix ${DESIGN_NAME}_${current_step} -outDir $report_dir/timingReports
		cp $report_dir/timingReports/${DESIGN_NAME}_${current_step}.summary.gz $report_dir/${DESIGN_NAME}.qor.setup.rpt.gz
		gzip -df $report_dir/${DESIGN_NAME}.qor.setup.rpt.gz

		foreach view [all_setup_analysis_views] {
				cp $report_dir/timingReports/${view}/${DESIGN_NAME}_${current_step}_all.tarpt.gz $report_dir/${DESIGN_NAME}.${view}.report_timing.max.gz
				gzip -df $report_dir/${DESIGN_NAME}.${view}.report_timing.max.gz
		}
}


###############################################################
# pre CTS
###############################################################
if {$current_step == "place"} {
		timeDesign -expandedViews -preCTS -prefix ${DESIGN_NAME}_${current_step} -outDir $report_dir/timingReports
		timeDesign -expandedViews -preCTS -hold -prefix ${DESIGN_NAME}_${current_step} -outDir $report_dir/timingReports

#		cp $report_dir/timingReports/${DESIGN_NAME}_${current_step}.summary.gz $report_dir/${DESIGN_NAME}.qor.setup.rpt.gz
#		cp $report_dir/timingReports/${DESIGN_NAME}_${current_step}_hold.summary.gz $report_dir/${DESIGN_NAME}.qor.hold.rpt.gz
#		cp $report_dir/timingReports/${DESIGN_NAME}_${current_step}.tran.gz $report_dir/${DESIGN_NAME}.max_tran.rpt.gz
#		cp $report_dir/timingReports/${DESIGN_NAME}_${current_step}.cap.gz $report_dir/${DESIGN_NAME}.max_cap.rpt.gz
#		cp $report_dir/timingReports/${DESIGN_NAME}_${current_step}.fanout.gz $report_dir/${DESIGN_NAME}.max_fanout.rpt.gz
#		cp $report_dir/timingReports/${DESIGN_NAME}_${current_step}.length.gz $report_dir/${DESIGN_NAME}.max_length.rpt.gz
#		gzip -df $report_dir/${DESIGN_NAME}.qor.setup.rpt.gz
#		gzip -df $report_dir/${DESIGN_NAME}.qor.hold.rpt.gz
#		gzip -df $report_dir/${DESIGN_NAME}.qor.max_tran.rpt.gz
#		gzip -df $report_dir/${DESIGN_NAME}.qor.max_cap.rpt.gz
#		gzip -df $report_dir/${DESIGN_NAME}.qor.max_fanout.rpt.gz
#		gzip -df $report_dir/${DESIGN_NAME}.qor.max_length.rpt.gz
#
#		foreach view [all_setup_analysis_views] {
#				cp $report_dir/timingReports/${view}/${DESIGN_NAME}_${current_step}_all.tarpt.gz $report_dir/${DESIGN_NAME}.${view}.report_timing.max.gz
#				gzip -df $report_dir/${DESIGN_NAME}.${view}.report_timing.max.gz
#		}
}

###############################################################
# post CTS
###############################################################
if {$current_step == "ccopt"} {
		timeDesign -expandedViews -postCTS -prefix ${DESIGN_NAME}_${current_step} -outDir $report_dir/timingReports
		timeDesign -expandedViews -postCTS -hold -prefix ${DESIGN_NAME}_${current_step} -outDir $report_dir/timingReports
		report_ccopt_clock_trees -file $report_dir/${DESIGN_NAME}.clock_tree_summary.rpt
		report_ccopt_skew_groups -file $report_dir/${DESIGN_NAME}.skew_group.rpt
		report_constraint -drv_violation_type {max_capacitance max_transition} -all_violators -clock > $report_dir/${DESIGN_NAME}.clock_drv_vio.rpt
}

###############################################################
# post route
###############################################################
if {$current_step == "route" || $current_step == "route_opt" || $current_step == "std_filler"} {
		timeDesign -expandedViews -postCTS -prefix ${DESIGN_NAME}_${current_step} -outDir $report_dir/timingReports
		timeDesign -expandedViews -postCTS -hold -prefix ${DESIGN_NAME}_${current_step} -outDir $report_dir/timingReports
		report_ccopt_clock_trees -file $report_dir/${DESIGN_NAME}.clock_tree_summary.rpt
		report_ccopt_skew_groups -file $report_dir/${DESIGN_NAME}.skew_group.rpt
		report_constraint -drv_violation_type {max_capacitance max_transition} -all_violators -clock > $report_dir/${DESIGN_NAME}.clock_drv_vio.rpt
		set_verify_drc_mode -check_implant false -ignore_cell_blockage true
		verify_drc -limit 0 -report $report_dir/${DESIGN_NAME}.verify_drc.rpt
}

report_constraint -all_violators > $report_dir/${DESIGN_NAME}.all_violation.rpt


redirect $report_dir/${DESIGN_NAME}.dontUse.rpt {foreach cell [dbGet [dbGet -p head.libCells.dontUse 1].name] {puts $cell}}

# check timing
check_timing -verbose > $report_dir/${DESIGN_NAME}.check_timing.rpt



puts "INFO: Completed script [info script]\n"


